# Adopting AI: How Familiarity Breeds Both Trust and Contempt Replication Code

# Packages

library(dplyr)
library(tidyverse)
library(ggplot2)
library(Hmisc)
library(wesanderson)
library(ggpubr)
library(corrplot)
library(circlize)

#---------- Data

cces18data <- spss.get("CCES18_PEN_OUTPUT.sav", use.value.labels=TRUE)

cces20data <- read.csv('CCES20_UPA_OUTPUT.csv')

#---------- Color Palette

pal1 <- wes_palette("Zissou1", 6, type = "continuous")

pal <- c(pal1[1],pal1[3],pal1[5],pal1[6])

pal3 <- wes_palette("Darjeeling1", 5, type = "continuous")

pal7 <- c(pal3[1],pal3[4],pal3[3],pal6[3], pal3[2],pal3[5])


#---------- Figure 1 in Paper

#----- Format Data
cces20dataSUWC <- cces20data %>%
  filter(!is.na(teamweight)) %>%
  select(caseid, pen320, pen325, pen315, pen331, pen322, pen328, pen317, pen333,
         pen321, pen326, pen327, pen316, pen332, pen323, pen329, pen318, pen334) %>%
  gather(key=question,value=response,c("pen320":"pen334")) %>%
  mutate(type = ifelse(question == "pen320" | question == "pen325" | question == "pen315" | question == "pen331", "Support",
                       ifelse(question == "pen322" | question == "pen328" | question == "pen317" | question == "pen333", "Use",
                              ifelse(question == "pen321" | question == "pen326" | question == "pen327" | question == "pen316" | question == "pen332", "Concern",
                                     ifelse(question == "pen323" | question == "pen329" | question == "pen318" | question == "pen334", "COVID-Support",
                                            ifelse(question == "pen324" | question == "pen330" | question == "pen319" | question == "pen335", "COVID-Use", "Other")))))) %>%
  mutate(application = ifelse(question == "pen320" | question == "pen322" | question == "pen321" | question == "pen323" | question == "pen324", "Autonomous Surgery",
                              ifelse(question == "pen325" | question == "pen328" | question == "pen326" | question == "pen327" | question == "pen329" | question == "pen330", "Autonomous Weapon Systems",
                                     ifelse(question == "pen315" | question == "pen317" | question == "pen316" | question == "pen318" | question == "pen319", "Autonomous Vehicles",
                                            ifelse(question == "pen331" | question == "pen333" | question == "pen332" | question == "pen334" | question == "pen335", "Autonomous Cyber Defense", "Other"))))) %>%
  mutate(survey = "CCES2020")

cces18dataSUWC <- cces18data %>%
  filter(!is.na(teamweight)) %>%
  mutate(caseid = as.numeric(caseid)) %>%
  filter(!is.na(caseid)) %>%
  select(caseid, PEN319, PEN323, PEN328, PEN332, PEN321, PEN326, PEN330, PEN334, PEN320, PEN324, PEN325, PEN329, PEN333) %>%
  gather(key=question,value=response,c("PEN319":"PEN333")) %>%
  mutate(type = ifelse(question == "PEN319" | question == "PEN323" | question == "PEN328" | question == "PEN332", "Support",
                       ifelse(question == "PEN321" | question == "PEN326" | question == "PEN330" | question == "PEN334", "Use",
                              ifelse(question == "PEN320" | question == "PEN324" | question == "PEN325" | question == "PEN329" | question == "PEN333", "Concern", "Other")))) %>%
  mutate(application = ifelse(question == "PEN319" | question == "PEN321" | question == "PEN320", "Autonomous Surgery",
                              ifelse(question == "PEN323" | question == "PEN326" | question == "PEN324" | question == "PEN325", "Autonomous Weapon Systems",
                                     ifelse(question == "PEN328" | question == "PEN330" | question == "PEN329", "Autonomous Vehicles",
                                            ifelse(question == "PEN332" | question == "PEN334" | question == "PEN333", "Autonomous Cyber Defense", "Other"))))) %>%
  mutate(survey = "CCES2018")

ccesdataSUWC <- cces20dataSUWC %>%
  full_join(cces18dataSUWC) %>%
  mutate(responseNumeric = ifelse(response == "Very Supportive" | response == "Very supportive" | response == "Very Unconcerned" | response == "Very unconcerned" | response == "Very Likely" | response == "Very likely", 4,
                                  ifelse(response == "Somewhat Supportive" | response == "Somewhat supportive" | response == "Somewhat Unconcerned" | response == "Somewhat unconcerned" | response == "Somewhat Likely" | response == "Somewhat likely", 3,
                                         ifelse(response == "Somewhat Unsupportive" | response == "Somewhat unsupportive" | response == "Somewhat Concerned" | response == "Somewhat concerned" | response == "Somewhat Unlikely" | response == "Somewhat unlikely", 2,
                                                ifelse(response == "Very Unsupportive" | response == "Very unsupportive" | response == "Very Concerned" | response == "Very concerned" | response == "Very Unlikely" | response == "Very unlikely", 1, 
                                                       ifelse(response == "Much more supportive" | response == "Much more likely", 5, 
                                                              ifelse(response == "Somewhat more supportive" | response == "Somewhat more likely",4,
                                                                     ifelse(response == "Neither more nor less likely" | response == "Neither more nor less supportive",3,
                                                                            ifelse(response == "Somewhat less supportive" | response == "Somewhat less likely",2,
                                                                                   ifelse(response == "Much less supportive" | response == "Much less likely",1,999)))))))))) %>%
  filter(responseNumeric != 999) %>%
  arrange(application) %>%
  mutate(question = ifelse(question == "PEN328", "PEN315", 
                           ifelse(question == "PEN330","PEN317",
                                  ifelse(question == "PEN329","PEN316",question))))


#----- Create Separate Plots
p1 <- ggplot(filter(ccesdataSUWC, type == "Support"), aes(x=question, y=responseNumeric, color =application, shape = survey)) + 
  stat_summary(fun.data = "mean_cl_normal") + 
  labs(x= "Support", y = expression(" " %<-% "   Less Supportive                            More Supportive   " %->% " ")) +
  theme_bw() +
  coord_flip() +
  scale_color_manual(values=pal) +
  theme(text= element_text(family="Times"),
        legend.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks.y = element_blank()) 

p2 <- ggplot(filter(ccesdataSUWC, type == "Concern"), aes(x=question, y=responseNumeric, color = application, shape = survey)) + 
  stat_summary(fun.data = "mean_cl_normal") +
  labs(x= "Concern", y = expression(" " %<-% "   More Concerned                            Less Concerned   " %->% " ")) +
  theme_bw() +
  coord_flip() +
  scale_color_manual(values=pal) +
  theme(text= element_text(family="Times"),
        legend.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks.y = element_blank()) +
  geom_text(aes(x= 8.5, label="Concern for civilians", y=1.591), family = "Times", size=1.75) +
  geom_text(aes(x= 7.5, label="Concern for militaries", y=1.828), family = "Times", size=1.75) +
  geom_text(aes(x= 6.5, label="Concern for civilians", y=1.572), family = "Times", size=1.75) +
  geom_text(aes(x= 5.5, label="Concern for militaries", y=1.851), family = "Times", size=1.75)

p3 <- ggplot(filter(ccesdataSUWC, type == "Use"), aes(x=question, y=responseNumeric, color =application, shape = survey)) + 
  stat_summary(fun.data = "mean_cl_normal") + 
  labs(x= "Use", y = expression(" " %<-% "   Less Likely to Use                            More Likely to Use   " %->% " ")) +
  theme_bw() +
  coord_flip() +
  scale_color_manual(values=pal) +
  theme(text= element_text(family="Times"),
        legend.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks.y = element_blank())

#----- Combine Plots
ggarrange(p1, p3, p2, ncol=1, nrow=3, common.legend = TRUE, legend="right")





#---------- Figure 2 in Paper

#----- Format Data
cyberVsWeapons <- ccesdataSUWC %>%
  filter(application == "Autonomous Weapon Systems" | application == "Autonomous Cyber Defense")

#----- Create Separate Plots
pCW1 <- ggplot(filter(cyberVsWeapons, type == "Support"), aes(x=question, y=responseNumeric, color =application, shape = survey)) + 
  stat_summary(fun.data = "mean_cl_normal") + 
  labs(x= "Support", y = expression(" " %<-% "   Less Supportive                            More Supportive   " %->% " ")) +
  theme_bw() +
  coord_flip() +
  scale_color_manual(values=pal) +
  theme(text= element_text(family="Times", size = 12),
        legend.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks.y = element_blank()) 


pCW2 <- ggplot(filter(cyberVsWeapons, type == "Concern"), aes(x=question, y=responseNumeric, color = application, shape = survey)) + 
  stat_summary(fun.data = "mean_cl_normal") +
  labs(x= "Concern", y = expression(" " %<-% "   More Concerned                            Less Concerned   " %->% " ")) +
  theme_bw() +
  coord_flip() +
  scale_color_manual(values=pal) +
  theme(text= element_text(family="Times", size = 12),
        legend.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks.y = element_blank())

pCW3 <- ggplot(filter(cyberVsWeapons, type == "Use"), aes(x=question, y=responseNumeric, color =application, shape = survey)) + 
  stat_summary(fun.data = "mean_cl_normal") + 
  labs(x= "Use", y = expression(" " %<-% "   Less Likely to Use                            More Likely to Use   " %->% " ")) +
  theme_bw() +
  coord_flip() +
  scale_color_manual(values=pal) +
  theme(text= element_text(family="Times", size = 12),
        legend.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks.y = element_blank())

#----- Combine Plots
ggarrange(pCW1, pCW3, pCW2, ncol=1, nrow=3, common.legend = TRUE, legend="right")


#---------- Figure 3 in Paper

#----- Format Data
aiprior <- cces20data %>%
  select(caseid, pen320, pen322, pen325, pen328, pen315, pen317, pen331, pen333, pen336, pen337, pen338, pen339) %>%
  mutate(pen338 = ifelse(pen338 == "Machine learning is not a type of AI","Correct","Incorrect")) %>%
  mutate(pen339 = ifelse(pen339 == "Principal Component Analysis","Correct","Incorrect")) %>%
  mutate(MLQuiz1 = ifelse(pen338 == "Correct",1,0)) %>%
  mutate(MLQuiz2 = ifelse(pen339 == "Correct",1,0)) %>%
  mutate(aihomework = ifelse(pen336 == "At home" | pen336 == "At work",1,
                             ifelse(pen336 == "Neither", 0,
                                    ifelse(pen336 == "At work and at home",2,999)))) %>%
  mutate(aimusicmovies = ifelse(pen337 == "Yes",1,0)) %>%
  mutate(aiprior = aihomework + aimusicmovies + MLQuiz1 + MLQuiz2) %>%
  filter(pen320 != "")

grid.coled2 = c("0" = pal7[1], "1" = pal7[2], "2" = pal7[3], "3" = pal7[4], "4" = pal7[5], "5" = pal7[6], "Very likely" = "grey", "Somewhat likely" = "grey", "Somewhat unlikely" = "grey", "Very unlikely" = "grey")

#----- Autonomous Surgery Subfigure

supportSurgery_aiprior <-  aiprior %>%
  count(aiprior, pen322) %>%
  group_by(aiprior, pen322) %>%
  summarise(sentiment_sum = sum(n)) %>%
  ungroup()

par(family = "Times", cex = 1.25, las = 3)
circos.clear()
circos.par(gap.after = c(rep(5, length(unique(supportSurgery_aiprior[[1]])) - 1), 15,
                         rep(5, length(unique(supportSurgery_aiprior[[2]])) - 1), 15))
chordDiagram(supportSurgery_aiprior, grid.col = grid.coled2, transparency = .2,
             order = c("5","4","3","2","1","0",
                       "Very unlikely","Somewhat unlikely","Somewhat likely", "Very likely"))
title("Autonomous Surgery")

#----- Autonomous Vehicles Subfigure

supportVehicles_aiprior <-  aiprior %>%
  count(aiprior, pen317) %>%
  group_by(aiprior, pen317) %>%
  summarise(sentiment_sum = sum(n)) %>%
  ungroup()

circos.clear()
circos.par(gap.after = c(rep(5, length(unique(supportVehicles_aiprior[[1]])) - 1), 15,
                         rep(5, length(unique(supportVehicles_aiprior[[2]])) - 1), 15))
chordDiagram(supportVehicles_aiprior, grid.col = grid.coled2, transparency = .2,
             order = c("5","4","3","2","1","0",
                       "Very unlikely","Somewhat unlikely","Somewhat likely", "Very likely"))
title("Autonomous Vehicles")


#----- Autonomous Weapons Subfigure
supportWeapons_aiprior <-  aiprior %>%
  count(aiprior, pen328) %>%
  group_by(aiprior, pen328) %>%
  summarise(sentiment_sum = sum(n)) %>%
  ungroup()

circos.clear()
circos.par(gap.after = c(rep(5, length(unique(supportWeapons_aiprior[[1]])) - 1), 15,
                         rep(5, length(unique(supportWeapons_aiprior[[2]])) - 1), 15))
chordDiagram(supportWeapons_aiprior, grid.col = grid.coled2, transparency = .2,
             order = c("5","4","3","2","1","0",
                       "Very unlikely","Somewhat unlikely","Somewhat likely", "Very likely"))
title("Autonomous Weapon Systems")


#----- Autonomous Cyber Defense Subfigure
supportCyber_aiprior <-  aiprior %>%
  count(aiprior, pen333) %>%
  group_by(aiprior, pen333) %>%
  summarise(sentiment_sum = sum(n)) %>%
  ungroup()

circos.clear()
circos.par(gap.after = c(rep(5, length(unique(supportCyber_aiprior[[1]])) - 1), 15,
                         rep(5, length(unique(supportCyber_aiprior[[2]])) - 1), 15))
chordDiagram(supportCyber_aiprior, grid.col = grid.coled2, transparency = .2,
             order = c("5","4","3","2","1","0",
                       "Very unlikely","Somewhat unlikely","Somewhat likely", "Very likely"))
title("Autonomous  Cyber Defense")

#---------- Figures 5-8 in Paper

#----- Format Data

ccesdataSUWCSUPPORTUSE <- ccesdataSUWC %>%
  filter(type == "Support" | type == "Use") %>%
  mutate(year = ifelse(survey == "CCES2020",2020,2018)) %>%
  select(caseid,year,application,type,response)

supportUseReorg <- ccesdataSUWCSUPPORTUSE %>%
  group_by(application, year, type, response) %>%
  summarise(n = n()) %>%
  mutate(N = 1000) %>%
  mutate(percent = n/N) %>%
  mutate(response = ifelse(response == "Very supportive", "Very Supportive",
                           ifelse(response == "Somewhat supportive", "Somewhat Supportive",
                                  ifelse(response == "Somewhat unsupportive", "Somewhat Unsupportive",
                                         ifelse(response == "Very unsupportive", "Very Unsupportive", response))))) %>%
  mutate(response = ifelse(response == "Very likely", "Very Likely",
                           ifelse(response == "Somewhat likely", "Somewhat Likely",
                                  ifelse(response == "Somewhat unlikely", "Somewhat Unlikely",
                                         ifelse(response == "Very unlikely", "Very Unlikely", response)))))

supportUseReorg2 <- supportUseReorg %>%
  select(application, type, response, year, percent) %>%
  spread(key = response, value = percent)

supportUse_new <- supportUseReorg2 %>%
  select(year, application, type, `Very Unsupportive`,`Somewhat Unsupportive`,`Somewhat Supportive`,`Very Supportive`,`Very Unlikely`, `Somewhat Unlikely`, `Somewhat Likely`, `Very Likely`) %>%
  mutate(`Somewhat Unsupportive` = -100*`Somewhat Unsupportive`) %>%
  mutate(`Very Unsupportive` = -100*`Very Unsupportive`) %>%
  mutate(`Somewhat Supportive` = 100*`Somewhat Supportive`) %>%
  mutate(`Very Supportive` = 100*`Very Supportive`) %>%
  mutate(`Very Unlikely` = -100*`Very Unlikely`) %>%
  mutate(`Somewhat Unlikely` = -100*`Somewhat Unlikely`) %>%
  mutate(`Somewhat Likely` = 100*`Somewhat Likely`) %>%
  mutate(`Very Likely` = 100*`Very Likely`)

supportUse_netperception <- supportUse_new %>%
  mutate(netperceptionSupport = `Somewhat Supportive`+`Very Supportive`+`Very Unsupportive`+`Somewhat Unsupportive`) %>%
  mutate(netperceptionSupport = round(netperceptionSupport,2)) %>%
  mutate(netperceptionUse = `Somewhat Likely`+`Very Likely`+`Very Unlikely`+`Somewhat Unlikely`) %>%
  mutate(netperceptionUse = round(netperceptionUse,2)) 

supportUse_yearApp <- supportUse_new %>%
  mutate(label = ifelse(application == "Autonomous Cyber Defense" & year == 2018 & type == "Support", "Policy Support for Autonomous Cyber Defense 2018",
                        ifelse(application == "Autonomous Cyber Defense" & year == 2020 & type == "Support","Policy Support for Autonomous Cyber Defense 2020",
                               ifelse(application == "Autonomous Surgery" & year == 2018 & type == "Support", "Policy Support for Autonomous Surgery 2018",
                                      ifelse(application == "Autonomous Surgery" & year == 2020 & type == "Support", "Policy Support for Autonomous Surgery 2020",
                                             ifelse(application == "Autonomous Vehicles" & year == 2018 & type == "Support", "Policy Support for Autonomous Vehicles 2018",
                                                    ifelse(application == "Autonomous Vehicles" & year == 2020 & type == "Support", "Policy Support for Autonomous Vehicles 2020",
                                                           ifelse(application == "Autonomous Weapon Systems" & year == 2018 & type == "Support", "Policy Support for Autonomous Weapon Systems 2018",
                                                                  ifelse(application == "Autonomous Weapon Systems" & year == 2020 & type == "Support", "Policy Support for Autonomous Weapon Systems 2020",NA))))))))) %>%
  mutate(label = ifelse(application == "Autonomous Cyber Defense" & year == 2018 & type == "Use", "Willingness to Use Autonomous Cyber Defense 2018",
                        ifelse(application == "Autonomous Cyber Defense" & year == 2020 & type == "Use","Willingness to Use Autonomous Cyber Defense 2020",
                               ifelse(application == "Autonomous Surgery" & year == 2018 & type == "Use", "Willingness to Use Autonomous Surgery 2018",
                                      ifelse(application == "Autonomous Surgery" & year == 2020 & type == "Use", "Willingness to Use Autonomous Surgery 2020",
                                             ifelse(application == "Autonomous Vehicles" & year == 2018 & type == "Use", "Willingness to Use Autonomous Vehicles 2018",
                                                    ifelse(application == "Autonomous Vehicles" & year == 2020 & type == "Use", "Willingness to Use Autonomous Vehicles 2020",
                                                           ifelse(application == "Autonomous Weapon Systems" & year == 2018 & type == "Use", "Willingness to Use Autonomous Weapon Systems 2018",
                                                                  ifelse(application == "Autonomous Weapon Systems" & year == 2020 & type == "Use", "Willingness to Use Autonomous Weapon Systems 2020",label)))))))))

x <- c("Very Unsupportive", "Somewhat Unsupportive", "Very Supportive", "Somewhat Supportive", "Very Unlikely","Somewhat Unlikely","Very Likely","Somewhat Likely")

supportUse_new2 <- supportUse_yearApp %>%
  gather(key=response,value=percent,c("Very Unsupportive":"Very Likely")) %>%
  group_by(label) %>%
  mutate(response = factor(response, levels = x)) %>%
  mutate(label =  factor(label, levels = c("Policy Support for Autonomous Vehicles 2018", "Policy Support for Autonomous Vehicles 2020", "Policy Support for Autonomous Surgery 2018", "Policy Support for Autonomous Surgery 2020","Policy Support for Autonomous Cyber Defense 2018", "Policy Support for Autonomous Cyber Defense 2020", "Policy Support for Autonomous Weapon Systems 2018","Policy Support for Autonomous Weapon Systems 2020",
                                           "Willingness to Use Autonomous Vehicles 2018", "Willingness to Use Autonomous Vehicles 2020", "Willingness to Use Autonomous Surgery 2018", "Willingness to Use Autonomous Surgery 2020","Willingness to Use Autonomous Cyber Defense 2018", "Willingness to Use Autonomous Cyber Defense 2020", "Willingness to Use Autonomous Weapon Systems 2018","Willingness to Use Autonomous Weapon Systems 2020"))) %>%
  arrange(label) %>%
  select(label,response,percent)%>%
  filter(!is.na(percent))

supportUseAWS <- supportUse_new2 %>%
  filter(str_detect(label, 'Weapon'))

supportUseCyber <- supportUse_new2 %>%
  filter(str_detect(label, 'Cyber'))

supportUseSurgery <- supportUse_new2 %>%
  filter(str_detect(label, 'Surgery'))

supportUseVehciles <- supportUse_new2 %>%
  filter(str_detect(label, 'Vehicles'))

palLikert <- wes_palette("Zissou1", 8, type = "continuous")

#----- Figure 5 Autonomous Surgery
ggplot() +
  geom_bar(stat = "identity",aes(x = label, y = percent, fill = response), data = supportUseSurgery) +
  coord_flip() +
  theme_minimal() +
  theme(text= element_text(family="Times"), panel.grid.major.y = element_line(colour = "grey", size=0.25), panel.grid.minor = element_blank(), panel.grid.major.x = element_blank(), 
        plot.title = element_text(hjust = 0.5), legend.title=element_text(size=8)) +
  scale_fill_manual(breaks = c('Very Unsupportive', 'Somewhat Unsupportive', 'Somewhat Supportive','Very Supportive',
                               'Very Unlikely','Somewhat Unlikely','Somewhat Likely','Very Likely'),
                    values = c('#3B9AB2','#5DAABC','#88BAAE','#CAC656','#E8C31E','#E2B306','#E86F00','#F21A00')) +
  labs(fill = " ", y = "Percentage", x = " ") +
  guides(fill=guide_legend(title.position = "top",ncol=2)) +
  ylim(-100,100) +
  ggtitle("") +
  geom_hline(yintercept = 0, color ="grey", size = 0.25) +
  geom_text(aes(x = label, y = percent, label = percent), position = position_stack(vjust = 0.5), size = 2.5, family = "Times",data = supportUseSurgery)

#----- Figure 6 Autonomous Vehicles
ggplot() +
  geom_bar(stat = "identity",aes(x = label, y = percent, fill = response), data = supportUseVehciles) +
  coord_flip() +
  theme_minimal() +
  theme(text= element_text(family="Times"), panel.grid.major.y = element_line(colour = "grey", size=0.25), panel.grid.minor = element_blank(), panel.grid.major.x = element_blank(), 
        plot.title = element_text(hjust = 0.5), legend.title=element_text(size=8)) +
  scale_fill_manual(breaks = c('Very Unsupportive', 'Somewhat Unsupportive', 'Somewhat Supportive','Very Supportive',
                               'Very Unlikely','Somewhat Unlikely','Somewhat Likely','Very Likely'),
                    values = c('#3B9AB2','#5DAABC','#88BAAE','#CAC656','#E8C31E','#E2B306','#E86F00','#F21A00')) +
  labs(fill = " ", y = "Percentage", x = " ") +
  guides(fill=guide_legend(title.position = "top",ncol=2)) +
  ylim(-100,100) +
  ggtitle("") +
  geom_hline(yintercept = 0, color ="grey", size = 0.25) +
  geom_text(aes(x = label, y = percent, label = percent), position = position_stack(vjust = 0.5), size = 2.5, family = "Times",data = supportUseVehciles)

#----- Figure 7 Autonomous Cyber Defense
ggplot() +
  geom_bar(stat = "identity",aes(x = label, y = percent, fill = response), data = supportUseCyber) +
  coord_flip() +
  theme_minimal() +
  theme(text= element_text(family="Times"), panel.grid.major.y = element_line(colour = "grey", size=0.25), panel.grid.minor = element_blank(), panel.grid.major.x = element_blank(), 
        plot.title = element_text(hjust = 0.5), legend.title=element_text(size=8)) +
  scale_fill_manual(breaks = c('Very Unsupportive', 'Somewhat Unsupportive', 'Somewhat Supportive','Very Supportive',
                               'Very Unlikely','Somewhat Unlikely','Somewhat Likely','Very Likely'),
                    values = c('#3B9AB2','#5DAABC','#88BAAE','#CAC656','#E8C31E','#E2B306','#E86F00','#F21A00')) +
  labs(fill = " ", y = "Percentage", x = " ") +
  guides(fill=guide_legend(title.position = "top",ncol=2)) +
  ylim(-100,100) +
  ggtitle("") +
  geom_hline(yintercept = 0, color ="grey", size = 0.25) +
  geom_text(aes(x = label, y = percent, label = percent), position = position_stack(vjust = 0.5), size = 2.5, family = "Times",data = supportUseCyber)

#----- Figure 8 Autonomous Weapons Systems
ggplot() +
  geom_bar(stat = "identity",aes(x = label, y = percent, fill = response), data = supportUseAWS) +
  coord_flip() +
  theme_minimal() +
  theme(text= element_text(family="Times"), panel.grid.major.y = element_line(colour = "grey", size=0.25), panel.grid.minor = element_blank(), panel.grid.major.x = element_blank(), 
        plot.title = element_text(hjust = 0.5), legend.title=element_text(size=8)) +
  scale_fill_manual(breaks = c('Very Unsupportive', 'Somewhat Unsupportive', 'Somewhat Supportive','Very Supportive',
                               'Very Unlikely','Somewhat Unlikely','Somewhat Likely','Very Likely'),
                    values = c('#3B9AB2','#5DAABC','#88BAAE','#CAC656','#E8C31E','#E2B306','#E86F00','#F21A00')) +
  labs(fill = " ", y = "Percentage", x = " ") +
  guides(fill=guide_legend(title.position = "top",ncol=2)) +
  ylim(-100,100) +
  ggtitle("") +
  geom_hline(yintercept = 0, color ="grey", size = 0.25) +
  geom_text(aes(x = label, y = percent, label = percent), position = position_stack(vjust = 0.5), size = 2.5, family = "Times",data = supportUseAWS)




